package com.tanhua.dubbo.api;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.OptionMapper;
import com.tanhua.model.domain.AAA;
import com.tanhua.model.domain.Option;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author fff
 * @date 2021/12/11 13:27
 **/
@DubboService
public class OptionApiImpl implements OptionApi{
    @Autowired
    private OptionMapper optionMapper;


    @Override
    public Integer score(String questionId, String optionId) {
        QueryWrapper<Option> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("question_id",questionId);
        queryWrapper.eq("id",optionId);

        Option option = optionMapper.selectOne(queryWrapper);



        return  option.getScore();
    }

    @Override
    public List<Option> selectlist(List<AAA> list) {
        List<String> list1 = CollUtil.getFieldValues(list, "optionId", String.class);

        QueryWrapper<Option> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id",list1);




        return optionMapper.selectList(queryWrapper);
    }
}
